<?php

namespace Addons\Attribute;
use Common\Controller\Addon;

/**
 * 自定义属性插件
 * @author Vicky
 */

    class AttributeAddon extends Addon{

        public $info = array(
            'name'=>'Attribute',
            'title'=>'自定义属性',
            'description'=>'自定义属性',
            'status'=>1,
            'author'=>'Vicky',
            'version'=>'1.0'
        );

        public function install(){
            return true;
        }

        public function uninstall(){
            return true;
        }

        //实现的Attribute钩子方法
        public function Attribute($param){
            $name = $param['name']?$param['name']:'files';
            $value = $param['value']?$param['value']:'[{}]';
            $valArr = json_decode($param['value'],true);
            if(count($valArr)==0){
                $valArr[0] = null;
            }
            $this->assign('attributes',$valArr);
            $this->assign('attributes_s',$value);
            $this->display('attribute');
        }


    }